package test.common;

import java.util.List;

import test.tokenizer.LabelTokenizer;
import test.tokenizer.StopWords;

import com.google.common.collect.Lists;

public class CommonUtils {
	/**
	 * get local name of an uri 
	 * @param uri
	 * @return
	 */
	public static String getLocalName(String uri) {
		String _return = "";
		int index = uri.lastIndexOf("#");
		_return = uri.substring(index + 1, uri.length());
		index = _return.lastIndexOf("/");
		if(index >= 0) {
			_return = _return.substring(index + 1, _return.length());
		}
		return _return;
		
	}
	public static List<String> cleanLabel(String label)
	{
		List<String> items	=	Lists.newArrayList();
		
		List<String> tokens	=	(new LabelTokenizer()).tokenize(label);
		
		for(String token : tokens)
		{
			token = token.replaceAll(" ", "");
			token = token.replaceAll("\"", "");
			token = token.replaceAll(";", "");
			token = token.toLowerCase();
			if(StopWords.getSmallSet().contains(token))
				continue;
			
			items.add(token);
		}
		
		return items;
	}
}
